//
//  YTServiceScoreViewController.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/5/18.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTServiceScoreViewController.h"
#import "YTUserProfileServices.h"

@interface YTServiceScoreViewController ()
@property (weak, nonatomic) IBOutlet UIView *firstView;
@property (weak, nonatomic) IBOutlet UIView *scondeView;
@property (weak, nonatomic) IBOutlet UIView *thirdView;
@property (weak, nonatomic) IBOutlet UILabel *serviceScoreText;
@property (weak, nonatomic) IBOutlet UILabel *numText;
@property (weak, nonatomic) IBOutlet UILabel *contractText;
@property (weak, nonatomic) IBOutlet UILabel *onboardText;
@property (weak, nonatomic) IBOutlet UILabel *arrivalText;
@end

@implementation YTServiceScoreViewController

- (void)dealloc {}

- (void)initialize {
    
    [[YTUserProfileServices driverServiceScore] subscribeNext:^(NSDictionary *response) {
        NSDictionary *data = response[@"responseData"];
        _serviceScoreText.text = [NSString stringWithFormat:@"您的服务保障评分: %.1f", [data[@"serviceScore"] floatValue]];
        _numText.text = [NSString stringWithFormat:@"第%@名", data[@"rank"]];
        _contractText.text = [NSString stringWithFormat:@"%.1f分/5.0分", [data[@"contactScore"] floatValue]];
        _onboardText.text = [NSString stringWithFormat:@"%.1f分/5.0分", [data[@"setOutScore"] floatValue]];
        _arrivalText.text = [NSString stringWithFormat:@"%.1f分/5.0分", [data[@"arriveScore"] floatValue]];
        [self creatViewWithWidthScale:[data[@"contactScore"] floatValue]/5.0 superView:_firstView];
        [self creatViewWithWidthScale:[data[@"setOutScore"] floatValue]/5.0 superView:_scondeView];
        [self creatViewWithWidthScale:[data[@"arriveScore"] floatValue]/5.0 superView:_thirdView];
    } error:^(NSError *error) {
        
    }];
}

- (void)creatViewWithWidthScale:(CGFloat)scale superView:(UIView *)superView {
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = kMainBlueColor;
    [superView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.and.bottom.equalTo(superView);
        make.width.equalTo(superView).multipliedBy(scale);
    }];
}

@end
